import {LoadableApp, registerMicroApps, start, initGlobalState} from "qiankun";

let state={}

// 初始化 state
const actions = initGlobalState(state);

let microData = null;
function MicroApps(apps:  LoadableApp<any>) {
    if (!microData) {
        microData = 1;
        registerMicroApps(apps, {
            beforeLoad: [
                (app) => {
                    // console.log(`${app.name}的beforeLoad阶段`);
                },
            ],
            beforeMount: [
                (app) => {
                    // console.log(`${app.name}的beforeMount阶段`);
                },
            ],
            afterMount: [
                (app) => {
                    // console.log(`${app.name}的afterMount阶段`);
                },
            ],
            beforeUnmount: [
                (app) => {
                    // console.log(`${app.name}的beforeUnmount阶段`);
                },
            ],
            afterUnmount: [
                (app) => {
                    // console.log(`${app.name}的afterUnmount阶段`);
                },
            ],
        });
        start();
    }
}

export default MicroApps;

export { actions }


